package com.gjm.tool.modifyLog.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.gjm.tool.modifyLog.domain.ModifyHistoryLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 修改历史记录Mapper接口
 *
 * @author admin
 */
@Mapper
public interface ModifyHistoryLogMapper extends BaseMapper<ModifyHistoryLog> {
    /**
     * 获取历史值
     *
     * @param tableName           表名
     * @param tablePrimaryIdName  表主键id名称
     * @param tablePrimaryIdValue 表主键值
     * @return 获取历史值
     */
    @Select("SELECT * from ${tableName} where ${tablePrimaryIdName} = ${tablePrimaryIdValue}")
    Map<String, Object> getOldData(@Param("tableName") String tableName,
                                   @Param("tablePrimaryIdName") String tablePrimaryIdName,
                                   @Param("tablePrimaryIdValue") String tablePrimaryIdValue);

    @Select("SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = '${tableName}'")
    List<String> getFields(@Param("tableName") String tableName);
}
